import { createHashRouter, Navigate } from 'react-router-dom'
import Layout from '../layout/default';
import Home from '../pages/home'
import Asset from '../pages/asset'
import Account from '../pages/account'
import SignIn from '../pages/login/signIn';
import SignUp from '../pages/login/signUp';
import Login from '../pages/login'
import Interest from '../pages/interest'
import NotFound from '../pages/notFound'

const router = createHashRouter([
  {
    path: '/',
    element: <Layout />,
    children: [
      {
        index: true, // 访问 '/' 会命中这里
        element: <Navigate to="/home" replace />, // 自动跳转
      },
      {
        path: '/home',
        element: <Home />
      },
      {
        path: '/asset/:id',
        element: <Asset />
      },
      {
        path: '/account/:id',
        element: <Account />
      },
      {
        path: '*',
        element: <NotFound />
      },
    ]
  },
  {
    path: '/interest',
    element: <Interest />
  },
  {
    path: '/login',
    element: <Login />,
    children: [
      {
        index: true, // 访问 '/' 会命中这里
        element: <Navigate to="/login/signIn" replace />, // 自动跳转
      },
      {
        path: '/login/signIn',
        element: <SignIn />
      },
      {
        path: '/login/signUp',
        element: <SignUp />
      }
    ]
  }
]);

export default router;